package cn.wk.servlet;

import cn.wk.entity.Teacher;
import cn.wk.services.TeacherServices;
import cn.wk.services.impl.TeacherServicesImpl;
import cn.wk.util.ConvertUtil;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/couByTeacher")
public class ServletcouByTeacher extends HttpServlet {
    private static TeacherServices ts=new TeacherServicesImpl();
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        List<Teacher>list=ts.getByTeacherNameandId();
        String s= ConvertUtil.ConvertToJson(list);
        response.setContentType("text/html;charset=utf-8");
        response.getWriter().println(s);
    }
}
